<%@ page language="java" %>
<%@ page import="java.util.ArrayList,
                java.util.HashMap,
                java.util.Iterator,
                com.scalar.chiptrack.finance.ProcessStepCostInfo,
                com.scalar.chiptrack.utils.ConfigManager" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>
<chiptrack:checkLogon sourcePage="/updateViewCost.do" />
<html:html>
<%String chipTracContext = "/" + ConfigManager.getChipTracContext(); try { %>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<meta http-equiv="Expires" content="text/html; charset=windows-1252"><LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>
<META content="MSHTML 5.50.4807.2300" name=GENERATOR>
<style type="text/css">
.costTable { border: 0px }
.costTable td { border: 1px solid white}
</style>
</HEAD>
<BODY bgColor='#ffffff' leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/update_view_cost.js"></script>

<script language='javascript'>
function updateCostInfo() {
	//validatePriceValues();
	if ( !validatePriceValues() )
		return;
   if ( document.updateViewCostForm.stdcost.value == "true")
   {
        document.updateViewCostForm.action = '<%=chipTracContext%>/updateViewCost.do?action=update&costType=Standard';
   }
   else
   {
        document.updateViewCostForm.action = '<%=chipTracContext%>/updateViewCost.do?action=update&costType=Projected';
   }
   document.updateViewCostForm.submit();
}

function showErrorReportPage()
{
    newWindow = window.open ('<%=chipTracContext%>/reportProblem.do','reportProblem','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=750,height=400,resizable=no');
    newWindow.focus();
}
function updateCurrentQuarterValues()
{
    document.updateViewCostForm.action = '<%=chipTracContext%>/updateViewCost.do?action=updateCurrentQuarterValuesByProduct';
    document.updateViewCostForm.submit();
}
</script>

<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<td width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->
<%@ include file="/jsp/finance/finance_menu.jsp" %>
<!-- end of the side navigations -->


<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->
<logic:notEqual value="true" name="prjaction">
<center><span class="NArialW">Update/View Standard Cost</span></center>
</logic:notEqual>
<logic:equal value="true" name="prjaction">
<center><span class="NArialW">Update/View Projected Cost</span></center>
</logic:equal>
<%
	boolean bool = false;
	String action = (String) request.getAttribute ("action");
    if (action == null)
        action = "view";
	if ( action.equals ("view") || action.equals ("prjview"))
		bool = true;
%>

<html:form name="updateViewCostForm" type="com.scalar.chiptrack.finance.forms.UpdateViewCostForm"  action="/updateViewCost.do?action=update"  scope="session">

<table border='0' width='100%' align='right'>
    <tr><td width="10%">&nbsp;</td><td width="90%"><chiptrack:info styleClass='NArialL'/><chiptrack:errors styleClass='NArialL'/>&nbsp;</td></tr>
    <tr><td width="10%">&nbsp;</td><td width="90%" align="left" class='NArialL'>&nbsp;<FONT id="errors" color='FF0000'>&nbsp;</font></td></tr>
    <logic:notEqual value="true" name="prjaction">
    <logic:notEqual value="view" name="action">
        <tr><td width="10%">&nbsp;</td><td width="90%" align="center" class='NArialL'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="javascript:updateCurrentQuarterValues()" class="leftsection">Update Current Quarter Values </a> &nbsp;for <bean:write name="updateViewCostForm" property="productName" />&nbsp;&nbsp;</td></tr>
    </logic:notEqual>
    </logic:notEqual>
    
    <tr>
		<td width="10%">&nbsp;</td><td width="90%" class="NArialL">Base Product : &nbsp;&nbsp;<bean:write name="updateViewCostForm" property="productName" /></td>
	</tr>
    <tr>
		<td width="10%">&nbsp;</td><td width="90%" class="NArialL">Financial Year : &nbsp;&nbsp;<bean:write name="updateViewCostForm" property="dateYear" /></td>
	</tr>
    <tr>
         <td width="10%">&nbsp;</td>
		 <td width="90%" valign='center' align='left' width='100%' >
            <html:hidden name="updateViewCostForm" property="productId" />
            <html:hidden name="updateViewCostForm" property="productName" />
            <html:hidden name="updateViewCostForm" property="dateYear" />
            <table border="0" width="80%" class="costTable" cellSpacing="0" cellPadding="0">
                <tr>
                    <td width="14%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Process Type</font></td>
                    <% if ( ConfigManager.isShowUpdateViewCostByLocation() )
                        { %>
                        <td width="14%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Location</font></td>
                    <%}%>

                    <td width="26%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Part Number</font></td>
                    <logic:notEqual value="true" name="prjaction">
                    <td colspan="4" width="40%" align="left" valign="top">
                        <table align="left" valign="top" border="0" width="100%" class="costTable" cellSpacing="0" cellPadding="0">
                            <tr>
                                <td width="25%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Quarter&nbsp;</font></td>
                                <td width="25%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Standard Cost</font></td>
                                <td width="25%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Yield</font></td>
                                <td width="25%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Copy</font></td>
                                <input type="hidden" name="stdcost" value="true">
                            </tr>
                       </table>
                    </td>
                    </logic:notEqual>
                    <logic:equal value="true" name="prjaction">
                        <td width="20%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Projected Cost</font></td>
                        <td width="20%" align="center" class="NArialL" bgcolor="#993333"><font color="#ffffff">Yield</font></td>
                        <input type="hidden" name="stdcost" value="false">
                    </logic:equal>
					<td width="10%">&nbsp;</td>
                    <!--start nested tag from here-->
                    <%int idd = 0;%>
                </tr>
                <nested:iterate id="costList" property="costList" type="com.scalar.chiptrack.finance.ProcessStepCostInfo" scope="session">
                <tr>
                    <td width="14%" class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:write property="processStepType"/><nested:hidden property="processStepId" /></td>
                    <% if ( ConfigManager.isShowUpdateViewCostByLocation() )
                        { %>
					<td width="14%" class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:write property="location"/><nested:hidden property="locationId" /></td>
                    <%}%>
                    <td width="22%" class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:write property="partNumber"/><nested:hidden property="partNumber" /></td>
                    <logic:notEqual value="true" name="prjaction">
                    <td colspan="4" width="40%" align="left" valign="top">
						<table border="0" width="100%" align="left" valign="top"  class="costTable" cellSpacing="0" cellPadding="0">
							<tr>
								<td nowrap width="25%" class="NArialL" bgcolor="#993333"><font color="#ffffff">Quarter1<%--<nested:write property="quarter1Label" filter="false"/></font>--%>&nbsp;</td>
								<td width="25%" class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q1StandardCost" onkeypress="javascript:restrictCharacters(this,5,4)" onkeyup="javascript:restrictAmt(this,5,4)" onfocus="javascript:this.select();" size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td width="25%" class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q1Yield" onkeypress="javascript:restrictCharacters(this,3,3)" onkeyup="javascript:restrictAmt(this,3,3)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td width="25%" class="NArialS" bgcolor="#DEE1E2"><logic:equal name="action" value="view"><IMG height="9" src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="65"></logic:equal><logic:notEqual name="action"  value="view"><input type="checkbox" name="chk<%=idd%>" onclick="javascript:copyValues(this,'<%=idd%>','1')">Q1&rarr;Q2</logic:notEqual></td>
							</tr>
							<tr>
								<td nowrap class="NArialL" bgcolor="#993333"><font color="#ffffff">Quarter2<%--<nested:write property="quarter2Label" filter="false"/>--%></font>&nbsp;</td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q2StandardCost" onkeypress="javascript:restrictCharacters(this,5,4)" onkeyup="javascript:restrictAmt(this,5,4)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q2Yield" onkeypress="javascript:restrictCharacters(this,3,3)" onkeyup="javascript:restrictAmt(this,3,3)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td class="NArialS" bgcolor="#DEE1E2"><logic:equal name="action" value="view">&nbsp;</logic:equal><logic:notEqual name="action"  value="view"><input type="checkbox" name="chk<%=idd%>" onclick="javascript:copyValues(this,'<%=idd%>','2')">Q2&rarr;Q3</logic:notEqual></td>
							</tr>
							<tr>
								<td nowrap class="NArialL" bgcolor="#993333"><font color="#ffffff">Quarter3<%--<nested:write property="quarter3Label" filter="false" />--%></font>&nbsp;</td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q3StandardCost" onkeypress="javascript:restrictCharacters(this,5,4)" onkeyup="javascript:restrictAmt(this,5,4)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q3Yield" onkeypress="javascript:restrictCharacters(this,3,3)" onkeyup="javascript:restrictAmt(this,3,3)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td class="NArialS" bgcolor="#DEE1E2"><logic:equal name="action" value="view">&nbsp;</logic:equal><logic:notEqual name="action"  value="view"><input type="checkbox" name="chk<%=idd%>" onclick="javascript:copyValues(this,'<%=idd%>','3')">Q3&rarr;Q4</logic:notEqual></td>
							</tr>
							<tr>
								<td nowrap class="NArialL" bgcolor="#993333"><font color="#ffffff">Quarter4<%--<nested:write property="quarter4Label" filter="false"/>--%></font>&nbsp;</td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q4StandardCost" onkeypress="javascript:restrictCharacters(this,5,4)" onkeyup="javascript:restrictAmt(this,5,4)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;<nested:text property="q4Yield" onkeypress="javascript:restrictCharacters(this,3,3)" onkeyup="javascript:restrictAmt(this,3,3)" onfocus="javascript:this.select();" size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
								<td class="NArialL" bgcolor="#DEE1E2">&nbsp;</td>
							</tr>
						</table>
                    </td>
                    </logic:notEqual>
                    <logic:equal value="true" name="prjaction">
                    	<td class="NArialL" align="center" bgcolor="#DEE1E2">&nbsp;<nested:text property="projectedCost" onkeypress="javascript:restrictCharacters(this,5,3)" onkeyup="javascript:restrictAmt(this,5,3)" onfocus="javascript:this.select();" size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
						<td class="NArialL" align="center" bgcolor="#DEE1E2">&nbsp;<nested:text property="projectedYield" onkeypress="javascript:restrictCharacters(this,3,3)" onkeyup="javascript:restrictAmt(this,3,3)" onfocus="javascript:this.select();"  size="9" maxlength="8" styleClass="valuetxfield" disabled="<%=bool%>"/></td>
                    </logic:equal>
 					<td width="10%">&nbsp;</td>
                    <% idd++; %><!--Very important please dont delete.-->
                </tr>
                </nested:iterate>
                <!--end nested tag here-->
                <% if ( idd == 0 ) {%>
                <tr><td colspan="9" class="NArialL"><br><font color='FF0000'>No matching records found.</font></td></tr>
                <% } %>
            </table>
        </td>
    </tr>
    <tr><td colspan='2'><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20><input type="hidden" name="count" value="<%=idd%>">

    </td></tr>
    <logic:match name="action" value="view">
    <tr>
        <td colspan='2' align='center'>
            <a href="<%=chipTracContext%>/updateViewCost.do"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/back.gif" width="39" height="17" onMouseOver="window.status='Click to go back';return true" onmouseout="window.status='';return true" title="Click here to go Back"></a>
        </td>
    </tr>
    </logic:match>

    <logic:match  name="action" value="allowupdate">
    <tr>
        <td colspan='3' align='center'>
            <% if ( idd > 0 ) {%>
                <a href="javascript:updateCostInfo()"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onMouseOver="window.status='Click to Update Cost';return true" onmouseout="window.status='';return true" title="Click here to Update Cost Details"></a>&nbsp;&nbsp;&nbsp;&nbsp;
                <a href="javascript:document.updateViewCostForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" onMouseOver="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"></a>&nbsp;&nbsp;&nbsp;&nbsp;
            <% } %>
            <a href="<%=chipTracContext%>/updateViewCost.do"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif"  onMouseOver="window.status='Click to Cancel';return true" onmouseout="window.status='';return true" title="Click here to Cancel"></a>
        </td>
    </tr>
    </logic:match>

</table>
</html:form>
<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</body>
<%
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
%>
</html:html>

